const Mock = require('mockjs')

const classList = ['计算机一班', '软件工程', '网络工程']

const studentList = []

const totalCount = 500

// const pageIndex = parseInt(paramObj.pageIndex)
// const pageSize = parseInt(paramObj.pageSize)
// const totalPage = Math.ceil(totalCount / pageSize)// 向上取整

// const startNo = (pageIndex - 1) * pageSize + 1// 计算开始Id
// const endNo = pageIndex < totalPage ? pageIndex * pageSize : totalCount

for (let i = 0; i <= totalCount; i++) {
  studentList.push(Mock.mock({
    studentId: i + 1,
    studentName: Mock.mock('@cname'),
    studentNo: Mock.mock('@natural(17434010103,17434010300)'),
    gender: Mock.mock('@natural(1,2)'),
    age: Mock.mock('@natural(18,22)'),
    registerTime: Mock.Random.date('yyyy-MM-dd'),
    address: Mock.Random.city(true),
    className: Mock.Random.pick(classList)

  }))
}

module.exports = [
  {
    url: '/vue-admin-template/table/studentPagedList',
    type: 'get',
    response: config => {
      // const { page = 1, limit = 20 } = config.query
      const page = config.query.pageIndex
      const limit = config.query.pageSize
      console.info(page)
      console.info(limit)
      debugger
      const pageList = studentList.filter((item, index) => index < limit * page && index >= limit * (page - 1))

      return {
        code: 20000,
        data: {
          total: totalCount,
          data: pageList
        }
      }
    }
  }
]
